package com.example.evaluate.controller;

import com.example.evaluate.service.StudentService;
import com.example.evaluate.service.TempService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class PageController {

    @Autowired
    TempService tempService;

    @RequestMapping("index")
    public String index(){
        return "index";
    }

    @RequestMapping("androidTest")
    public String androidTest(){
        return "androidTest";
    }

    @RequestMapping("admin")
    public String admin(Model model,HttpSession session){
        if (session.getAttribute("admin")==null||session.getAttribute("admin").equals("")){
            model.addAttribute("errorMessage","Error Message：登陆不合法！！！");
            return "error";

        }else {
            return "admin";
        }
    }

    @RequestMapping("addStudentPage")
    public String addStudentPage(Model model){
        model.addAttribute("test","添加学生");
        return "addStudentPage";
    }

    @RequestMapping("addCoursePage")
    public String addCoursePage(Model model){
        model.addAttribute("test","添加课程");
        return "addCoursePage";
    }

    @RequestMapping("getStudentInfoPage")
    public String getStudentInfoPage(Model model){
        model.addAttribute("studentInfo",tempService.getAllStudentInfo());

        return "getStudentInfoPage";
    }

    @RequestMapping("getStudentInfoPageClass16")
    public String getStudentInfoPageClass16(Model model){
        model.addAttribute("studentInfo",tempService.getStudentInfoByClass("16"));
        model.addAttribute("tag","班级 16自动化");

        return "getStudentInfoPage";
    }

    @RequestMapping("getStudentInfoPageClass17")
    public String getStudentInfoPageClass17(Model model){
        model.addAttribute("studentInfo",tempService.getStudentInfoByClass("17"));
        model.addAttribute("tag","班级 17自动化");
        return "getStudentInfoPage";
    }

    @RequestMapping("getStudentInfoPageClass18")
    public String getStudentInfoPageClass18(Model model){
        model.addAttribute("studentInfo",tempService.getStudentInfoByClass("18"));
        model.addAttribute("tag","班级 18自动化");
        return "getStudentInfoPage";
    }

    @RequestMapping("getTeacherInfoPage")
    public String getTeacherInfo(Model model){

        model.addAttribute("teacherInfo",tempService.getAllTeacherInfo());

        return "getTeacherInfoPage";
    }

}
